﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TinyERP.Framework.Controls
{
    public class KRibbonTab : RibbonTab, ILocalizable
    {
        public string ResourceModuleKey { get; set; }
        public string ResourceKey { get; set; }
        public void UpdateLanguage()
        {
            string textFromResource = "";
            if (!string.IsNullOrEmpty(this.ResourceModuleKey))
            {
                textFromResource = ModuleResourceManager.GetInstance().GetStringFromModuleResourceKey(ResourceModuleKey);
            }
            else
            {
                textFromResource = AppResourceManager.GetInstance().GetString(ResourceKey);
            }
            if (!string.IsNullOrEmpty(textFromResource))
            {
                this.Text = textFromResource;
            }
            foreach (RibbonPanel panel in this.Panels)
            {
                foreach (RibbonItem ribbonItem in panel.Items)
                {
                    if (ribbonItem is ILocalizable)
                    {
                        ((ILocalizable)ribbonItem).UpdateLanguage();
                    }
                }
            }
        }
    }
}
